﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using nplJobsCommon.JobSeeker;
using System.Data;

namespace nplJobsDAL.Select
{
    public class SelectFieldOfStudy : DataAccessBase
    {

        public SelectFieldOfStudy()
        {
            StoredProcedureName = StoredProcedure.Name.spFieldOfStudy.ToString();
        }

        #region GetCareerLevel
        public List<nplJobsCommon.JobSeeker.FieldOfStudy> GetFieldOfstudy()
        {
            DataBaseHelper dbHelper;
            DataSet dsFieldOfstudy;

            try
            {
                dbHelper = new DataBaseHelper(StoredProcedureName);
                dsFieldOfstudy = dbHelper.Run(base.ConnectionString);
                return GetList(dsFieldOfstudy);
            }
            catch (Exception)
            {

                throw;
            }
        }
        #endregion

        #region GetList
        private List<nplJobsCommon.JobSeeker.FieldOfStudy> GetList(DataSet dsFieldOfstudy)
        {
            List<nplJobsCommon.JobSeeker.FieldOfStudy> fieldOfstudies;
            try
            {
                fieldOfstudies = (from n in dsFieldOfstudy.Tables[0].AsEnumerable()
                                  select new nplJobsCommon.JobSeeker.FieldOfStudy
                                   {
                                       ID = n.Field<int>("ID"),
                                       StudyArea = n.Field<string>("StudyArea")
                                   }).ToList();

                return fieldOfstudies;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message.ToString());
            }
            finally { }
        }
        #endregion
    }
}
